<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.nickname" placeholder="姓名" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="姓名" width="180px" prop="nickname" />
      <el-table-column label="证书名称" min-width="200px" :formatter="fileFormatter" />
      <el-table-column label="证书扫描件" width="240px">
        <template slot-scope="{row}">
          <span v-for="(item, index) in row.fs" :key="index" class="mr10">
            <a style="color: blue"  href="javascript:void(0)" @click="handleWV(item.u)">{{ item.n }}</a><br>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="发证日期" align="center" width="110px" prop="begin_time" />
      <el-table-column label="有效期至" align="center" width="110px" prop="end_time" />
      <el-table-column label="备注" min-width="260px" prop="remark" />
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
  </div>
</template>

<script>
import { credentials } from '@/api/personnel/credential'
import page from '@/utils/page'

export default {
  name: '',
  components: { },
  extends: page,
  props: {
    reqList: {
      default: credentials,
      type: Function
    }
  },
  data() {
    return {
    }
  },
  created() {
    this.getList()
  },
  methods: {
    fileFormatter(e, c) {
      const files = e.files
      const fs = []
      if (files) {
        const array = files.split(',')
        if (array.length > 0) {
          array.forEach(element => {
            const js = element.split('#')
            const f = {}
            f.n = js[0]
            f.u = js[1]
            fs.push(f)
          })
        }
      }
      e.fs = fs

      return e.name
    }
  }
}
</script>
